import { useUserStore } from '@/stores/modules';

export const hasPermission = (code: string | string[]) => {
  const userStore = useUserStore();
  const c = Array.isArray(code) ? code : [code];
  const allPermission = '*:*:*';
  const result = c.some((code) => {
    return (
      userStore.permissions.includes(allPermission) ||
      userStore.permissions.includes(code)
    );
  });
  return result;
};
